{% extends "CmsBundle::base.html.twig" %}

{% block pluginStyles %}
    <link rel="stylesheet" href="/assets/cms/css/chosen.css" />
{% endblock %}

{% block pageContent %}
    <!-- PAGE CONTENT BEGINS -->
    <form class="form-horizontal" role="form" action="{{ path("yearnfar_cms_menu_edit") }}" method="post">
        <div class="form-group">
            <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 菜单名称： </label>
            <div class="col-sm-9">
                <input type="hidden" name="mid" class="col-xs-10 col-sm-5" value="{{ current.id }}">
                <input type="text" name="name" class="col-xs-10 col-sm-5" value="{{ current.name | raw }}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 上一级菜单： </label>
            <div class="col-sm-9">
                <select class="width-20 chosen-select" name="pid" id="form-field-select-3" data-placeholder="上一级菜单">
                    <option value="0">顶级菜单</option>

                    {% for item in menu %}
                        {% if item.id==current.pid %}
                            <option value="{{ item.id }}" selected="selected">{{ item.name2 | raw }}</option>
                        {% elseif item.id!=current.id %}
                            <option value="{{ item.id }}">{{ item.name2 | raw }}</option>
                        {% endif %}
                    {% endfor %}
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 路由： </label>
            <div class="col-sm-9">
                <input type="text" name="route" class="col-xs-10 col-sm-5" value="{{ current.route }}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 样式： </label>
            <div class="col-sm-9">
                <input type="text" name="class" class="col-xs-10 col-sm-5" value="{{ current.class }}">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 权限设置： </label>
            <div class="col-sm-4">
                <table>
                    {% for k, item in groups %}
                    <!-- 一行3个 -->
                    {% if k % 3==0 %}
                    <tr>
                        {% endif %}
                        <td class="col-xs-1">
                            <label class="block">
                                <input name="power[]" type="checkbox" value="{{ item.privilege }}" class="ace"{% if k==0 %} checked="checked" disabled="" {% elseif current.power b-and 2 ** item.privilege %} checked="checked" {% endif %}>
                                <span class="lbl"> {{ item.name }} </span>
                            </label>
                        </td>
                        {% endfor %}
                    <tr>
                </table>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 描述： </label>
            <div class="col-sm-9">
                <textarea class="col-sm-4 col-xs-3" style="width: 500px;height: 150px;" name="description">{{ current.description }}</textarea>
            </div>
        </div>

        <div class="clearfix form-actions">
            <div class="col-md-offset-3 col-md-9">
                <button class="btn btn-info" type="submit" name="submit" value="1">
                    <i class="icon-ok bigger-110"></i>
                    提交
                </button>

                &nbsp; &nbsp; &nbsp;
                <button class="btn" type="reset">
                    <i class="icon-undo bigger-110"></i>
                    重置
                </button>
            </div>
        </div>
    </form>
    <!-- PAGE CONTENT ENDS -->
{% endblock %}

{% block pluginScripts %}
    <script src="/assets/cms/js/chosen.jquery.min.js"></script>
{% endblock %}

{% block inlineScripts %}
    <script type="text/javascript">
        $(".chosen-select").chosen();
    </script>
{% endblock %}